/*
--Archivo: test_banderas.c
--Fecha de creacion: 22/01/2011.
--Ultima fecha de modificacion: 04/02/2011.
--Diseñador: Miguel Peña.
--Diseño: Banco de pruebas del detector de estados.
--Proposito: Asignar estimulos a los puertos de entrada y detectar el estado del mismo.
*/

#include <stdio.h>
#include "genpat.h"

char* inttostr(int entier) {
  char* str;
  str = (char *) mbkalloc (32 * sizeof(char));
  sprintf(str,"%d",entier);
  return(str);
}
main() {
 
  DEF_GENPAT("test_ban");

  DECLAR("C_i"       ,":2","B", IN   ,	      ""      , "");
  DECLAR("C_PREV_i"  ,":2","B", IN   ,	      ""      , "");
  DECLAR("I_i"       ,":2","B", IN   ,	"3 downto 0"  , "");
  DECLAR("S_o"       ,":2","B", OUT  ,	"3 downto 0"  , "");
  DECLAR("CARRY_o"   ,":2","B", OUT  ,	      ""      , "");
  DECLAR("OVF_o"     ,":2","B", OUT  ,	      ""      , "");    
  DECLAR("N_o"       ,":2","B", OUT  ,	      ""      , "");
  DECLAR("Z_o"       ,":2","B", OUT  ,	      ""      , "");        
  DECLAR("vdd"       ,":2","B", IN   ,	      ""      , "");
  DECLAR("vss"       ,":2","B", IN   ,	      ""      , "");

  LABEL("test_banderas");
  
  SETTUNIT("ns");
  AFFECT("0" , "vdd"	, "1"); 
  AFFECT("0" , "vss"	, "0");

  AFFECT("0"    , "I_i"      ,  "0b0000");//0
  AFFECT("0"    , "C_PREV_i" ,       "0");
  AFFECT("0"    , "C_i"      ,       "0");


  AFFECT("+50"    , "I_i"     , "0b0001");//(+3)+(-2)= +1
  AFFECT("+0"    , "C_PREV_i" ,      "1");
  AFFECT("+0"    , "C_i"      ,     "1");

  AFFECT("+50"    , "I_i"     ,  "0b1010");//(+6)+(+4)
  AFFECT("+0"    , "C_PREV_i" ,       "1");
  AFFECT("+0"    , "C_i"      ,       "0");

  AFFECT("+50"    , "I_i"     , "0b0101");//(+3)-(-2) = +5
  AFFECT("+0"    , "C_PREV_i" ,      "0");
  AFFECT("+0"    , "C_i"      ,      "0");

  AFFECT("+50"    , "I_i"     , "0b1110");//(-1)+(-1) = (-2)
  AFFECT("+0"    , "C_PREV_i" ,      "1");
  AFFECT("+0"    , "C_i"      ,      "1");

    SAV_GENPAT();

  exit(0);
}

/* vim: tabstop=2 : expandtab : shiftwidth=2
*/
